<?php

function delTree($dir) {
   $files = array_diff(scandir($dir), array('.','..'));
    foreach ($files as $file) {
      (is_dir("$dir/$file")) ? delTree("$dir/$file") : unlink("$dir/$file");
    }
    return rmdir($dir);
}

// arr1 is het origineel, dat wordt overschreven met gegevens uit arr2.
function extend($arr1, $arr2 ) {
    $keys = array_keys($arr2);
    foreach( $keys as $key ) {
        if (isset($arr1[$key]) && (gettype($arr1[$key])==gettype($arr2[$key])) && (in_array(gettype($arr1[$key]), array("object","array")))) {
            $arr1[$key] = extend( $arr1[$key], $arr2[$key] );
        } else {
            $arr1[$key] = $arr2[$key];
        }
    }
    return $arr1;
}
